#include "Comm.hpp"
#include"Fifo.hpp"
int main()
{
    key_t key = GetShmKeyOrDie();
    cout<<ToHex(key)<<endl;
    int shmid = GetShm(key,defaultsize);
    cout<<"shmid:"<<shmid<<endl;
    // 挂接共享内存
    char* shmaddr = (char*)ShmAttach(shmid);
      // 将共享内存中的数据全部清空.


    memset(shmaddr,0,defaultsize);
    Sync syn;
    syn.OpenWriteOrDie();

    // 开始通信
    for(char c = 'A';c<='Z';c++)
    {
        *shmaddr = c;
        cout<<"client send:"<<c<<endl;
        shmaddr++;
        sleep(1);
        syn.Wakeup();
    }
    //去关联
    ShmDetach(shmaddr);
    cout<<"shmDetach success!!"<<endl;
    return 0;
}